home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / beveled-pattern-arrow.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  4.9 KB  |  161 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Beveled pattern arrow for web pages
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software: you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21.  
  22. (define (script-fu-beveled-pattern-arrow size orientation pattern)
  23.  
  24.   (define (make-point x y)
  25.     (cons x y)
  26.   )
  27.  
  28.   (define (point-x p)
  29.     (car p)
  30.   )
  31.  
  32.   (define (point-y p)
  33.     (cdr p)
  34.   )
  35.  
  36.   (define (point-list->double-array point-list)
  37.     (let* (
  38.           (how-many (length point-list))
  39.           (a (cons-array (* 2 how-many) 'double))
  40.           (count 0)
  41.           )
  42.  
  43.       (for-each (lambda (p)
  44.                   (aset a (* count 2) (point-x p))
  45.                   (aset a (+ 1 (* count 2)) (point-y p))
  46.                   (set! count (+ count 1)))
  47.                 point-list
  48.       )
  49.       a
  50.     )
  51.   )
  52.  
  53.   (define (rotate-points points size orientation)
  54.     (map (lambda (p)
  55.            (let ((px (point-x p))
  56.                  (py (point-y p)))
  57.              (cond ((= orientation 0) (make-point px py))           ; right
  58.                    ((= orientation 1) (make-point (- size px) py))  ; left
  59.                    ((= orientation 2) (make-point py (- size px)))  ; up
  60.                    ((= orientation 3) (make-point py px))           ; down
  61.              )
  62.            )
  63.          )
  64.          points
  65.     )
  66.   )
  67.  
  68.   (define (make-arrow size offset)
  69.     (list (make-point offset offset)
  70.           (make-point (- size offset) (/ size 2))
  71.           (make-point offset (- size offset)))
  72.   )
  73.  
  74.   ; the main function
  75.  
  76.   (let* (
  77.         (img (car (gimp-image-new size size RGB)))
  78.         (background (car (gimp-layer-new img size size RGB-IMAGE "Arrow" 100 NORMAL-MODE)))
  79.         (bumpmap (car (gimp-layer-new img size size RGB-IMAGE "Bumpmap" 100 NORMAL-MODE)))
  80.         (big-arrow (point-list->double-array (rotate-points (make-arrow size 6) size orientation)))
  81.         (med-arrow (point-list->double-array (rotate-points (make-arrow size 7) size orientation)))
  82.         (small-arrow (point-list->double-array (rotate-points (make-arrow size 8) size orientation)))
  83.         )
  84.  
  85.     (gimp-context-push)
  86.  
  87.     (gimp-image-undo-disable img)
  88.     (gimp-image-add-layer img background -1)
  89.     (gimp-image-add-layer img bumpmap -1)
  90.  
  91.     ; Create pattern layer
  92.  
  93.     (gimp-context-set-background '(0 0 0))
  94.     (gimp-edit-fill background BACKGROUND-FILL)
  95.     (gimp-context-set-pattern pattern)
  96.     (gimp-edit-bucket-fill background PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
  97.  
  98.     ; Create bumpmap layer
  99.  
  100.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  101.  
  102.     (gimp-context-set-background '(127 127 127))
  103.     (gimp-rect-select img 1 1 (- size 2) (- size 2) CHANNEL-OP-REPLACE FALSE 0)
  104.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  105.  
  106.     (gimp-context-set-background '(255 255 255))
  107.     (gimp-rect-select img 2 2 (- size 4) (- size 4) CHANNEL-OP-REPLACE FALSE 0)
  108.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  109.  
  110.     (gimp-context-set-background '(127 127 127))
  111.     (gimp-free-select img 6 big-arrow CHANNEL-OP-REPLACE TRUE FALSE 0)
  112.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  113.  
  114.     (gimp-context-set-background '(0 0 0))
  115.     (gimp-free-select img 6 med-arrow CHANNEL-OP-REPLACE TRUE FALSE 0)
  116.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  117.  
  118.     (gimp-selection-none img)
  119.  
  120.     ; Bumpmap
  121.  
  122.     (plug-in-bump-map RUN-NONINTERACTIVE img background bumpmap 135 45 2 0 0 0 0 TRUE FALSE 0)
  123.  
  124.     ; Darken arrow
  125.  
  126.     (gimp-context-set-background '(255 255 255))
  127.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  128.  
  129.     (gimp-context-set-background '(192 192 192))
  130.     (gimp-free-select img 6 small-arrow CHANNEL-OP-REPLACE TRUE FALSE 0)
  131.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  132.  
  133.     (gimp-selection-none img)
  134.  
  135.     (gimp-layer-set-mode bumpmap MULTIPLY-MODE)
  136.  
  137.     (gimp-image-flatten img)
  138.  
  139.     (gimp-image-undo-enable img)
  140.     (gimp-display-new img)
  141.  
  142.     (gimp-context-pop)
  143.   )
  144. )
  145.  
  146.  
  147. (script-fu-register "script-fu-beveled-pattern-arrow"
  148.   _"_Arrow..."
  149.   _"Create a beveled pattern arrow for webpages"
  150.   "Federico Mena Quintero"
  151.   "Federico Mena Quintero"
  152.   "July 1997"
  153.   ""
  154.   SF-ADJUSTMENT _"Size"        '(32 5 150 1 10 0 1)
  155.   SF-OPTION     _"Orientation" '(_"Right" _"Left" _"Up" _"Down")
  156.   SF-PATTERN    _"Pattern"     "Wood"
  157. )
  158.  
  159. (script-fu-menu-register "script-fu-beveled-pattern-arrow"
  160.                          "<Image>/File/Create/Web Page Themes/Beveled Pattern")
  161.